﻿<Window x:Class="RL.wRouteDeparture"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:RL"
        Title="Выходы транспортных средств" Height="300" Width="438" Loaded="Window_Loaded">
    <Window.Resources>
        <local:ScheduleConverter x:Key="ScheduleConverter"/>
        <CollectionViewSource x:Key="sourceDeparture"/>
        <DataTemplate x:Key="cellDeparture">
            <TextBox Text="{Binding Path=numberDeparture}" GotFocus="TextBox_GotFocus" />
        </DataTemplate>
        <DataTemplate x:Key="cellDays">
            <!--<local:ucDayWeeks ScheduleID="{Binding Path=id_schedule, Mode=TwoWay}" />-->
            <TextBlock Text="{Binding Path=Schedule, Mode=OneWay, Converter={StaticResource ScheduleConverter}}"  />
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="36" />
            <RowDefinition Height="225*" />
        </Grid.RowDefinitions>
        <StackPanel Name="stackPanel1" Orientation="Horizontal">
            <Button Content="Добавить" Height="23" Name="buttonAdd" Width="75" Click="buttonAdd_Click" />
            <Button Content="Удалить" Height="23" Name="buttonDelete" Width="75" Click="buttonDelete_Click" IsEnabled="False"/>
            <Button Content="Редактировать" Height="23" Name="buttonEdit" Width="107" Click="buttonEdit_Click" />
            <Button Content="Сохранить" Height="23" Name="buttonSave" Width="75" Click="buttonSave_Click"/>
        </StackPanel>
        <ListView Grid.Row="1" Name="listView1" ItemsSource="{Binding Source={StaticResource sourceDeparture}}" SelectionMode="Single">
            <!-- <ListView.ItemContainerStyle>
               <Style TargetType="ListViewItem">
                    <Style.Triggers>
                        <Trigger Property="IsKeyboardFocusWithin" Value="True">
                            <Setter Property="IsSelected" Value="True"/>
                        </Trigger>
                    </Style.Triggers>
                </Style> 
            </ListView.ItemContainerStyle> -->
            <ListView.ItemContainerStyle>
                <Style TargetType="{x:Type ListViewItem}">
                    <EventSetter Event="PreviewGotKeyboardFocus" Handler="SelectCurrentItem"/>
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Выход" Width="135" CellTemplate="{StaticResource cellDeparture}" />
                    <GridViewColumn Header="Расписание" Width="180" CellTemplate="{StaticResource cellDays}" />
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>
</Window>
